Name: 'GridSearchResults',
Extends: SearchResultsBase,
- _init: function(provider) {
+ _init: function(provider, parentContainer) {
this.parent(provider);
+ // We need to use the parent container to know how much results we can show.
+ // None of the actors in this class can be used for that, since the main actor
+ // goes hidden when no results are displayed, and then it lost its allocation.
+ // Then on the next use of _getMaxDisplayedResults allocation is 0, en therefore
+ // it doesn't show any result although we have some.
+ this._parentContainer = parentContainer;
this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
xAlign: St.Align.START });
},
_getMaxDisplayedResults: function() {
- return this._grid.columnsForWidth(this._bin.width) * this._grid.getRowLimit();
+ let parentThemeNode = this._parentContainer.get_theme_node();
+ let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width);
+ return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit();
},
_renderResults: function(metas) {
if (provider.appInfo)
providerDisplay = new ListSearchResults(provider);
else
- providerDisplay = new GridSearchResults(provider);
+ providerDisplay = new GridSearchResults(provider, this._content);
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this._content.add(providerDisplay.actor);